<template>
	<view>
		<view class="firstPart">
			<view class="accountTitle">
				<view class="flex heightForty">
					<view class="goldColor">账户余额</view>
					<!-- <view style="color: #FFFFFF;">提现流程</view> -->
				</view>
				<view class="flex goldColor account">
					<view>￥{{dataInfo.available_money||0}}</view>
					<view class="fontSizeFourtee">最低提现￥{{dataInfo.minimal_withdraw_limit||0}}<text class="depositBtn" @click="toWithdraw">提现</text></view>
				</view>
			</view>
		</view>
		<view style="width: 100vw;height: 8px;background-color: #EFEFEF;"></view> <!-- 分割线 -->
		<!-- 收入情况 -->
		<view class="marginTwenty">
			<view class="heightForty">收入情况</view>
			<view class="flex">
				<view style="width: 50%;text-align: center;border-right: 1px solid #dadada;">
					<view class="greenColor moneyCss">￥{{dataInfo.section_time_total_money||0}}</view>
					<view class="grayColor">本月佣金收入</view>
				</view>
				<view style="width: 50%;text-align: center;">
					<view class="greenColor moneyCss">￥{{dataInfo.total_money||0}}</view>
					<view class="grayColor">累计佣金收益</view>
				</view>
			</view>
		</view>
		<view style="width: 100vw;height: 8px;background-color: #EFEFEF;"></view> <!-- 分割线 -->
		<!-- 订单情况 -->
		<view class="marginTwenty">
			<view class="heightForty">订单情况</view>
			<view class="flex">
				<view style="width: 50%;text-align: center;border-right: 1px solid #dadada;">
					<view class="greenColor moneyCss">{{dataInfo.section_time_total_order_num||0}}</view>
					<view class="grayColor">本月分销/单</view>
				</view>
				<view style="width: 50%;text-align: center;">
					<view class="greenColor moneyCss">{{dataInfo.total_order_num||0}}</view>
					<view class="grayColor">累计分销/单</view>
				</view>
			</view>
		</view>
		<view style="width: 100vw;height: 8px;background-color: #EFEFEF;"></view> <!-- 分割线 -->
		<!-- 操作 -->
		<view>
			<u-sticky>
				<u-tabs :list="list" :is-scroll="false" active-color="#2CB85F" bar-width="120" :current="current" @change="change"></u-tabs>
			</u-sticky>
			<!-- 后台获取到的数据 -->
			<view class="marginTwenty" id="itemData" style="margin-top: 20px;">
				<!-- current==0使用orderList佣金明细列表   current==1使用recordList提现记录列表-->
				<view v-if="current==0 && commissions_list!=''">
					<view v-for="(item,index) in commissions_list" :key="index">
						<view class="flex" style="margin-bottom: 10px;">
							<view class="greenColor">￥{{item.amount}}</view>
							<view class="grayColor">{{item.arrival_time}}</view>
						</view>
						<view class="flex grayColor">
							<view>订单号：{{item.order_num}}</view>
							<view>{{item.from_user_info.nickname}}</view>
						</view>
						<!-- 分割线 -->
						<view style="width: 100vw;height: 1px;background-color: #d6d6d6;margin-top: 10px;margin-bottom: 10px;margin-left: -30px;"></view>
					</view>
				</view>
				<view v-if="current==1 && withdraw_list!=''">
					<view v-for="(item,index) in withdraw_list" :key="index">
						<view class="flex" style="margin-bottom: 10px;">
							<view class="greenColor">-￥{{item.withdraws_amount}}</view>
							<view class="greenColor">{{item.status_name}}</view>
						</view>
						<view class="flex grayColor">
							<view>提现方式：{{item.withdraws_way}}</view>
							<view>{{item.submit_time}}</view>
						</view>
						<!-- 分割线 -->
						<view style="width: 100vw;height: 1px;background-color: #d6d6d6;margin-top: 10px;margin-bottom: 10px;margin-left: -30px;"></view>
					</view>
				</view>
				<view v-if="commissions_list=='' || withdraw_list==''" style="text-align: center;margin-top: 20px;color: #B5B5B5;">
					<se-empty>没有更多了</se-empty>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataInfo: "",
				commissions_list: [], //佣金明细
				withdraw_list: [], //提现记录
				list: [{
						name: "佣金明细"
					},
					{
						name: "提现记录"
					}
				],
				current: 0
			};
		},
		onReachBottom() {
			console.log("触底了")
		},
		onPageScroll(e) {
			console.log(e)
		},
		onShow() {
			this.getUserDistributionInfo()
		},
		mounted() {
			console.log("this.$refs.itemData")
			var query = wx.createSelectorQuery();
			query.select('#itemData').boundingClientRect()
			query.exec((res) => {
				console.log(res)
				var listHeight = res[0].height; // 获取list高度
			})
			console.log(query)
		},
		methods: {
			//去提现页面
			toWithdraw() {
				wx.navigateTo({
					url: "withDraw/withDraw?available_money=" + this.dataInfo.available_money + "&&minimal_withdraw_limit=" + this.dataInfo
						.minimal_withdraw_limit
				})
			},
			change(index) {
				this.current = index
			},
			getUserDistributionInfo() {
				console.log("dddd")
				let params = {
					user_token: wx.getStorageSync("userToken")
				}
				console.log(params)
				this.$api.getUserDistributionInfo(params, this.$baseUrl).then(res => {
					if (res.data.level == "success") {
						this.dataInfo = res.data.data
						this.commissions_list = res.data.data.commissions_list
						this.withdraw_list = res.data.data.withdraw_list
					} else {
						wx.showToast({
							title: res.data.message,
							icon: "none"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.firstPart {
		background-color: #0CBB5D;
		padding: 15px;

		.accountTitle {
			padding: 20px;
			background-color: #2C2C2C;
			border-radius: 12px;
		}

		.account {
			height: 60px;
			line-height: 60px;
		}
	}

	.marginTwenty {
		margin: 15px;
	}

	.fontSizeFourtee {
		font-size: 14px;
	}

	.heightForty {
		height: 40px;
		color: #313131;
	}

	.flex {
		display: flex;
		justify-content: space-between;
	}

	.moneyCss {
		font-size: 20px;
		margin-bottom: 10px;
	}

	.greenColor {
		color: #2CB85F;
	}

	.goldColor {
		color: #F2C991;
	}

	.grayColor {
		color: #8E9190;
		font-size: 14px;
	}

	.depositBtn {
		display: inline-block;
		width: 80px;
		height: 35px;
		line-height: 35px;
		background: #F2C991;
		color: #101010;
		border-radius: 30px;
		text-align: center;
		margin-left: 10px;
	}
</style>
